package com.next

class Option implements Comparable
{

    String name
    Integer displayOrder = 0
    static belongsTo = [question: Question]

    static mapping = {
        table 'question_option'
    }

    static constraints = {
        name maxSize: 64, unique: ['question']
    }

    @Override
    int compareTo(Object Option)
    {

        def option = (Option) Option
        if (displayOrder == option.displayOrder)
        {
            return 0
        }
        else if (displayOrder > option.displayOrder)
        {
            return 1
        }
        else
        {
            return -1
        }
    }
}
